home *** CD-ROM | disk | FTP | other *** search
/ Scene Storm / Scene Storm - Volume 1.iso / coding / c / toollib / source / gadget.s < prev    next >
Text File  |  1995-12-30  |  22KB  |  524 lines

  1.                 opt     l+,o+,ow-
  2. *
  3. *   gadget.s version 8.1 - © Copyright 1990 Jaba Development
  4. *
  5. *   Author    : Jan van den Baard
  6. *   Assembler : Devpac version 2.14
  7. *
  8.         incdir  'sys:devpac_inc/'
  9.         include 'mymacros.i'
  10.         include 'exec/memory.i'
  11.         include 'exec/exec_lib.i'
  12.         include 'intuition/intuition.i'
  13.         include 'intuition/intuition_lib.i'
  14.         include 'graphics/graphics_lib.i'
  15.  
  16.         xref    _IntuitionBase
  17.         xref    _GfxBase
  18.  
  19.         xdef    TestBits
  20.         xdef    SelectGadget
  21.         xdef    DeSelectGadget
  22.         xdef    MutualExclude
  23.         xdef    MutualInclude
  24.         xdef    EraseGadget
  25.         xdef    GadgetOn
  26.         xdef    GadgetOff
  27.         xdef    SelectTest
  28.         xdef    ShadowGadget
  29.         xdef    OnGList
  30.         xdef    OffGList
  31.         xdef    SelectGList
  32.         xdef    DeSelectGList
  33.         xdef    ShadowGList
  34.         xdef    EraseGList
  35.  
  36. TestBits:       and.l   d1,d0
  37.                 cmp.l   d0,d1
  38.                 beq.s   BitsSet
  39.                 cldat   d0
  40.                 rts
  41. BitsSet:        moveq   #1,d0
  42.                 rts
  43.  
  44.  
  45. SelectGadget:   movem.l d2-d4/a2-a3/a6,-(sp)
  46.                 move.l  a0,d2                   ; window in d2
  47.                 move.l  a1,a3                   ; gadget in a3
  48.                 move.l  a2,d3                   ; requester in d3
  49.                 move.w  gg_Activation(a3),d0
  50.                 andi.w  #TOGGLESELECT,d0        ; TOGGLESELECT ?
  51.                 bne.s   IsTog                   ; yes, try to select it
  52. EndSG:          movem.l (sp)+,d2-d4/a2-a3/a6
  53.                 rts
  54. IsTog:          move.w  gg_Flags(a3),d0
  55.                 andi.w  #SELECTED,d0            ; SELECTED ?
  56.                 bne.s   EndSG                   ; yes, dont do anything
  57.                 bsr.s   SwitchSel               ; select it
  58.                 bra.s   EndSG
  59.  
  60. DeSelectGadget: movem.l d2-d4/a2-a3/a6,-(sp)
  61.                 move.l  a0,d2                   ; window in d2
  62.                 move.l  a1,a3                   ; gadget in a3
  63.                 move.l  a2,d3                   ; requester in d3
  64.                 move.w  gg_Activation(a3),d0
  65.                 andi.w  #TOGGLESELECT,d0        ; TOGGLESELECT ?
  66.                 bne.s   IsTogg                  ; yes, try to deselect it
  67. EndDSG:         movem.l (sp)+,d2-d4/a2-a3/a6
  68.                 rts
  69. IsTogg:         move.w  gg_Flags(a3),d0
  70.                 andi.w  #SELECTED,d0            ; SELECTED ?
  71.                 beq.s   EndDSG                  ; no, dont do anything
  72.                 bsr.s   SwitchSel               ; deselect it
  73.                 bra.s   EndDSG
  74.  
  75. SwitchSel:      move.l  a3,a0
  76.                 move.l  d2,a1
  77.                 move.l  d3,a2
  78.                 moveq   #1,d0
  79.                 move.l  _IntuitionBase,a6
  80.                 libcall RefreshGList            ; refresh the gadget
  81.                 move.l  d2,a0
  82.                 move.l  a3,a1
  83.                 moveq   #1,d0
  84.                 libcall RemoveGList             ; remove the gadget
  85.                 move.l  d0,d4
  86.                 eori.w  #SELECTED,gg_Flags(a3)  ; toggle selected flag
  87.                 move.l  d2,a0
  88.                 move.l  a3,a1
  89.                 move.l  d4,d0
  90.                 moveq   #1,d1
  91.                 move.l  d3,a2
  92.                 libcall AddGList                ; add the gadget
  93.                 move.l  a3,a0
  94.                 move.l  d2,a1
  95.                 move.l  d3,a2
  96.                 moveq   #1,d0
  97.                 libcall RefreshGList            ; refresh the gadget
  98.                 rts
  99.  
  100. MutualExclude:  movem.l d2-d6/a2-a3/a6,-(sp)
  101.                 move.l  a0,d2                   ; window in d2
  102.                 move.l  a1,a0                   ; gadget that excludes in a0
  103.                 move.l  a3,d3                   ; requester in d3
  104.                 move.l  a2,a3                   ; first gadget in a3
  105.                 move.l  gg_MutualExclude(a0),d5
  106.                 tst.l   d5                      ; mutual exclude bits set ?
  107.                 bne.s   MustExcl                ; yes, try to exclude them
  108. EndME:          movem.l (sp)+,d2-d6/a2-a3/a6
  109.                 rts
  110. MustExcl:       cldat   d6
  111. ExclLoop:       btst    d6,d5                   ; bit set ?
  112.                 beq.s   NotExcl                 ; no, skip this one
  113.                 bchg    d6,d5                   ; clear bit
  114.                 move.l  d3,a2                   ; requester in a2
  115.                 move.l  a3,a1                   ; gadget in a1
  116.                 move.l  d2,a0                   ; window in a0
  117.                 bsr     DeSelectGadget          ; deselect the gadget
  118. NotExcl:        cmpi.l  #31,d6                  ; had 32 bits ?
  119.                 beq.s   EndME                   ; yes, done
  120.                 inc.l   d6                      ; increase counter
  121.                 tst.l   d5                      ; bits left ?
  122.                 beq.s   EndME                   ; no, done
  123.                 move.l  gg_NextGadget(a3),a3
  124.                 cmpa.l  #0,a3                   ; gadgets left ?
  125.                 beq.s   EndME                   ; no, done
  126.                 bra.s   ExclLoop
  127.  
  128. MutualInclude:  movem.l d2-d6/a2-a3/a6,-(sp)
  129.                 move.l  a0,d2                   ; window in d2
  130.                 move.l  a1,a0                   ; gadget that includes in a0
  131.                 move.l  a3,d3                   ; requester in d3
  132.                 move.l  a2,a3                   ; firrst gadget in a3
  133.                 move.l  gg_MutualExclude(a0),d5
  134.                 tst.l   d5                      ; mutual include bits set ?
  135.                 bne.s   MustIncl                ; yes, try to include them
  136. EndMI:          movem.l (sp)+,d2-d6/a2-a3/a6
  137.                 rts
  138. MustIncl:       cldat   d6
  139. InclLoop:       btst    d6,d5                   ; bit set ?
  140.                 beq.s   NotIncl                 ; no, skip this one
  141.                 bchg    d6,d5                   ; clear bit
  142.                 move.l  d3,a2                   ; requester in a2
  143.                 move.l  a3,a1                   ; gadget in a1
  144.                 move.l  d2,a0                   ; window in a0
  145.                 bsr     SelectGadget            ; select the gadget
  146. NotIncl:        cmpi.l  #31,d6                  ; had 32 bits ?
  147.                 beq.s   EndMI                   ; yes, done
  148.                 inc.l   d6                      ; increase counter
  149.                 tst.l   d5                      ; bits left ?
  150.                 beq.s   EndMI                   ; no, done
  151.                 move.l  gg_NextGadget(a3),a3
  152.                 cmpa.l  #0,a3                   ; gadgets left ?
  153.                 beq.s   EndMI                   ; no, done
  154.                 bra.s   InclLoop
  155.  
  156. EraseGadget:    movem.l d2-d4/a2-a3/a6,-(sp)
  157.                 move.l  a0,d2                   ; window in d2
  158.                 move.l  a1,a3                   ; gadget in a3
  159.                 move.l  a2,d3                   ; requester in d3
  160.                 tst.l   d3                      ; is ther a requester ?
  161.                 beq.s   NotReq                  ; no.. use window rastport
  162.                 move.l  d3,a0
  163.                 move.l  rq_ReqLayer(a0),a0
  164.                 move.l  lr_rp(a0),a0            ; layer rastport to a0
  165.                 bra.s   GotRP
  166. NotReq:         move.l  d2,a0
  167.                 move.l  wd_RPort(a0),a0         ; get window rastport
  168. GotRP:          move.l  a0,d4                   ; rastport to d4
  169.                 cldat   d0
  170.                 move.b  rp_DrawMode(a0),d0      ; old drawmode to d0
  171.                 move.l  d0,-(sp)                ; save old DrawModes
  172.                 move.l  d4,a1
  173.                 tst.l   d3                      ; is there a requester ?
  174.                 beq.s   BackGround              ; no
  175.                 move.l  d3,a0
  176.                 moveq   #0,d0
  177.                 move.b  rq_BackFill(a0),d0      ; requester backfill color
  178.                 bra.s   SetPen
  179. BackGround:     cldat   d0                      ; use color 0
  180. SetPen:         move.l  _GfxBase,a6
  181.                 libcall SetAPen                 ; set frontpen
  182.                 move.l  d4,a1
  183.                 moveq   #RP_JAM1,d0
  184.                 libcall SetDrMd                 ; set drawmodes
  185.                 move.l  a3,a0
  186.                 move.l  d2,a1
  187.                 move.l  d3,a2
  188.                 moveq   #1,d0
  189.                 move.l  _IntuitionBase,a6
  190.                 libcall RefreshGList            ; refresh the gadget
  191.                 move.l  d4,a1
  192.                 movem.l d2/d3,-(sp)
  193.                 cldat   d0
  194.                 cldat   d1
  195.                 cldat   d2
  196.                 cldat   d3
  197.                 move.w  gg_LeftEdge(a3),d0
  198.                 dec.w   d0
  199.                 move.w  gg_TopEdge(a3),d1
  200.                 dec.w   d1
  201.                 move.w  d0,d2
  202.                 move.w  d1,d3
  203.                 inc.w   d2
  204.                 inc.w   d3
  205.                 add.w   gg_Width(a3),d2
  206.                 add.w   gg_Height(a3),d3
  207.                 move.l  _GfxBase,a6
  208.                 libcall RectFill                ; clear gadget area
  209.                 movem.l (sp)+,d2/d3
  210.                 move.l  gg_GadgetText(a3),d0
  211.                 tst.l   d0
  212.                 beq     NoTexts                 ; branch if no texts
  213.                 move.l  d0,-(sp)
  214.                 move.l  #it_SIZEOF,d0
  215.                 move.l  #MEMF_PUBLIC+MEMF_CLEAR,d1
  216.                 move.l  _SysBase,a6
  217.                 libcall AllocMem                ; allocate text buffer
  218.                 move.l  (sp)+,a0
  219.                 move.l  d0,a2
  220.                 beq.s   NoTexts
  221. TextLoop:       move.l  it_IText(a0),it_IText(a2)
  222.                 move.l  it_ITextFont(a0),it_ITextFont(a2)
  223.                 move.w  it_TopEdge(a0),it_TopEdge(a2)
  224.                 move.w  it_LeftEdge(a0),it_LeftEdge(a2)
  225.                 move.b  #RP_JAM2,it_DrawMode(a2)
  226.                 tst.l   d3
  227.                 beq.s   Null
  228.                 move.l  d3,a1
  229.                 move.b  rq_BackFill(a1),it_FrontPen(a2)
  230.                 move.b  rq_BackFill(a1),it_BackPen(a2)
  231. Null:           move.l  it_NextText(a0),-(sp)
  232.                 move.l  d4,a0
  233.                 move.l  a2,a1
  234.                 cldat   d0
  235.                 cldat   d1
  236.                 move.w  gg_LeftEdge(a3),d0
  237.                 move.w  gg_TopEdge(a3),d1
  238.                 move.l  _IntuitionBase,a6
  239.                 libcall PrintIText              ; erase the texts
  240.                 move.l  (sp)+,d0
  241.                 tst.l   d0
  242.                 beq.s   NoMoreTexts             ; branch if all text erased
  243.                 move.l  d0,a0
  244.                 bra.s   TextLoop
  245. NoMoreTexts:    move.l  a2,a1
  246.                 move.l  #it_SIZEOF,d0
  247.                 move.l  _SysBase,a6
  248.                 libcall FreeMem                 ; free the text buffer
  249. NoTexts:        move.l  d4,a1
  250.                 move.l  (sp)+,d0
  251.                 move.l  _GfxBase,a6
  252.                 libcall SetDrMd                 ; reset old DrawModes
  253.                 movem.l (sp)+,d2-d4/a2-a3/a6
  254.                 rts
  255.  
  256. GadgetOn:       movem.l d2-d4/a2-a3/a6,-(sp)
  257.                 move.l  a0,d2                   ; window in d2
  258.                 move.l  a1,a3                   ; gadget in a3
  259.                 move.l  a2,d3                   ; requester in d3
  260.                 move.w  gg_Flags(a3),d0
  261.                 andi.w  #GADGDISABLED,d0        ; GADGDISABLED  ?
  262.                 beq.s   EndGON                  ; no, dont do anything
  263.                 bsr.s   SwitchDis               ; switch gadget on
  264. EndGON:         movem.l (sp)+,d2-d4/a2-a3/a6
  265.                 rts
  266.  
  267. GadgetOff:      movem.l d2-d4/a2-a3/a6,-(sp)
  268.                 move.l  a0,d2                   ; window in d2
  269.                 move.l  a1,a3                   ; gadget in a3
  270.                 move.l  a2,d3                   ; requester in d3
  271.                 move.w  gg_Flags(a3),d0
  272.                 andi.w  #GADGDISABLED,d0        ; GADGDISABLED ?
  273.                 bne.s   EndGOF                  ; yes, dont do anything
  274.                 bsr.s   SwitchDis               ; switch gadget off
  275. EndGOF:         movem.l (sp)+,d2-d4/a2-a3/a6
  276.                 rts
  277.  
  278. SwitchDis:      move.l  d3,a2
  279.                 move.l  a3,a1
  280.                 move.l  d2,a0
  281.                 bsr     EraseGadget             ; erase the gadget
  282.                 move.l  d2,a0
  283.                 move.l  a3,a1
  284.                 moveq   #1,d0
  285.                 move.l  _IntuitionBase,a6
  286.                 libcall RemoveGList             ; remove the gadget
  287.                 eori.w  #GADGDISABLED,gg_Flags(a3) ; flip the GADGDISABLED flag
  288.                 move.l  d2,a0
  289.                 move.l  a3,a1
  290.                 moveq   #1,d1
  291.                 move.l  d3,a2
  292.                 libcall AddGList                ; add the gadget
  293.                 move.l  a3,a0
  294.                 move.l  d2,a1
  295.                 move.l  d3,a2
  296.                 moveq   #1,d0
  297.                 libcall RefreshGList            ; refresh the gadget
  298.                 rts
  299.  
  300. SelectTest:     move.w  gg_Flags(a0),d0
  301.                 andi.w  #SELECTED,d0            ; SELECTED set ?
  302.                 bne.s   IsSelected              ; yes
  303.                 cldat   d0
  304.                 rts
  305. IsSelected:     moveq   #1,d0
  306.                 rts
  307.  
  308. ShadowGadget:   movem.l d2-d7/a2-a3/a6,-(sp)
  309.                 move.l  a0,d2                   ; window in d2
  310.                 move.l  a1,a3                   ; gadget in a3
  311.                 move.l  a2,d3                   ; requester in d3
  312.                 move.l  d0,d4                   ; color in d4
  313.                 tst.l   d3                      ; is there a requester ?
  314.                 beq.s   NoReq                   ; no
  315.                 move.l  d3,a0
  316.                 move.l  rq_ReqLayer(a0),a0
  317.                 move.l  lr_rp(a0),a0            ; get requester rastport
  318.                 bra.s   RP
  319. NoReq:          move.l  d2,a0
  320.                 move.l  wd_RPort(a0),a0         ; get window rastport
  321. RP:             move.l  a0,a2                   ; rastport to a2
  322.                 cldat   d0
  323.                 move.b  rp_DrawMode(a0),d0
  324.                 move.l  d0,-(sp)                ; save old DrawModes
  325.                 moveq   #RP_JAM1,d0
  326.                 move.l  a2,a1
  327.                 move.l  _GfxBase,a6
  328.                 libcall SetDrMd                 ; set drawmodes
  329.                 move.l  d4,d0
  330.                 move.l  a2,a1
  331.                 libcall SetAPen                 ; set frontpen
  332.                 cldat   d4
  333.                 cldat   d5
  334.                 cldat   d6
  335.                 cldat   d7
  336.                 move.w  gg_LeftEdge(a3),d4
  337.                 move.w  gg_TopEdge(a3),d5
  338.                 move.w  gg_Width(a3),d6
  339.                 move.w  gg_Height(a3),d7
  340.                 add.w   d5,d7
  341.                 add.w   d4,d6
  342.                 move.l  a2,a1
  343.                 move.l  d6,d0
  344.                 inc.l   d0
  345.                 move.l  d5,d1
  346.                 addq.l  #2,d1
  347.                 libcall Move                    ; move cursor
  348.                 move.l  a2,a1
  349.                 move.l  d6,d0
  350.                 inc.l   d0
  351.                 move.l  d7,d1
  352.                 inc.l   d1
  353.                 libcall Draw                    ; draw a line
  354.                 move.l  a2,a1
  355.                 move.l  d6,d0
  356.                 addq.l  #2,d0
  357.                 move.l  d5,d1
  358.                 addq.l  #2,d1
  359.                 libcall Move                    ; move cursor
  360.                 move.l  a2,a1
  361.                 move.l  d6,d0
  362.                 addq.l  #2,d0
  363.                 move.l  d7,d1
  364.                 inc.l   d1
  365.                 libcall Draw                    ; draw a line
  366.                 move.l  a2,a1
  367.                 move.l  d4,d0
  368.                 addq.l  #4,d0
  369.                 move.l  d7,d1
  370.                 inc.l   d1
  371.                 libcall Move                    ; move cursor
  372.                 move.l  a2,a1
  373.                 move.l  d6,d0
  374.                 inc.l   d0
  375.                 move.l  d7,d1
  376.                 inc.l   d1
  377.                 libcall Draw                    ; draw a line
  378.                 move.l  a2,a1
  379.                 move.l  (sp)+,d0
  380.                 libcall SetDrMd                 ; reset old DrawModes
  381.                 movem.l (sp)+,d2-d7/a2-a3/a6
  382.                 rts
  383.  
  384. OnGList:        movem.l d2-d5/a2,-(sp)
  385.                 move.l  a0,d2                   ; window in d2
  386.                 move.l  d0,d4                   ; numgadgets in d4
  387.                 move.l  a1,d0                   ; gadget in d0
  388.                 move.l  a2,d3                   ; requester in d3
  389.                 cldat   d5
  390. OnLoop:         move.l  d0,a2                   ; gadget to a2
  391.                 tst.l   d0                      ; anymore gadgets ?
  392.                 beq.s   NoMoreOn                ; no, done
  393.                 move.l  a2,-(sp)
  394.                 move.l  d2,a0                   ; window in a0
  395.                 move.l  a2,a1                   ; gadget in a1
  396.                 move.l  d3,a2                   ; requester in a2
  397.                 bsr     GadgetOn                ; switch gadget on
  398.                 move.l  (sp)+,a2
  399.                 inc.l   d5                      ; increase counter
  400.                 cmp.l   d5,d4                   ; all done ?
  401.                 beq.s   NoMoreOn                ; yes
  402.                 move.l  gg_NextGadget(a2),d0
  403.                 bra.s   OnLoop
  404. NoMoreOn:       movem.l (sp)+,d2-d5/a2
  405.                 rts
  406.  
  407. OffGList:       movem.l d2-d5/a2,-(sp)
  408.                 move.l  a0,d2                   ; window in d2
  409.                 move.l  d0,d4                   ; numgadgets in d4
  410.                 move.l  a1,d0                   ; gadget in d0
  411.                 move.l  a2,d3                   ; requester in d3
  412.                 cldat   d5
  413. OffLoop:        move.l  d0,a2
  414.                 tst.l   d0                      ; any more gadgets ?
  415.                 beq.s   NoMoreOff               ; no, done
  416.                 move.l  a2,-(sp)
  417.                 move.l  d2,a0
  418.                 move.l  a2,a1
  419.                 move.l  d3,a2
  420.                 bsr     GadgetOff               ; switch gadget off
  421.                 move.l  (sp)+,a2
  422.                 inc.l   d5                      ; increase counter
  423.                 cmp.l   d5,d4                   ; all done ?
  424.                 beq.s   NoMoreOff               ; yes
  425.                 move.l  gg_NextGadget(a2),d0
  426.                 bra.s   OffLoop
  427. NoMoreOff:      movem.l (sp)+,d2-d5/a2
  428.                 rts
  429.  
  430. SelectGList:    movem.l d2-d5/a2,-(sp)
  431.                 move.l  a0,d2                   ; window in d2
  432.                 move.l  d0,d4                   ; numgadgets in d4
  433.                 move.l  a1,d0                   ; gadget in d0
  434.                 move.l  a2,d3                   ; requester in d3
  435.                 cldat   d5
  436. SelLoop:        move.l  d0,a2
  437.                 tst.l   d0
  438.                 beq.s   NoMoreSel
  439.                 move.l  a2,-(sp)
  440.                 move.l  d2,a0
  441.                 move.l  a2,a1
  442.                 move.l  d3,a2
  443.                 bsr     SelectGadget
  444.                 move.l  (sp)+,a2
  445.                 inc.l   d5
  446.                 cmp.l   d5,d4
  447.                 beq.s   NoMoreSel
  448.                 move.l  gg_NextGadget(a2),d0
  449.                 bra.s   SelLoop
  450. NoMoreSel:      movem.l (sp)+,d2-d5/a2
  451.                 rts
  452.  
  453. DeSelectGList:  movem.l d2-d5/a2,-(sp)
  454.                 move.l  a0,d2                   ; window in d2
  455.                 move.l  d0,d4                   ; numgadgets in d4
  456.                 move.l  a1,d0                   ; gadget in d0
  457.                 move.l  a2,d3                   ; requester in d3
  458.                 cldat   d5
  459. DSelLoop:       move.l  d0,a2
  460.                 tst.l   d0
  461.                 beq.s   NoMoreDSel
  462.                 move.l  a2,-(sp)
  463.                 move.l  d2,a0
  464.                 move.l  a2,a1
  465.                 move.l  d3,a2
  466.                 bsr     DeSelectGadget
  467.                 move.l  (sp)+,a2
  468.                 inc.l   d5
  469.                 cmp.l   d5,d4
  470.                 beq.s   NoMoreDSel
  471.                 move.l  gg_NextGadget(a2),d0
  472.                 bra.s   DSelLoop
  473. NoMoreDSel:     movem.l (sp)+,d2-d5/a2
  474.                 rts
  475.  
  476. ShadowGList:    movem.l d2-d6/a2,-(sp)
  477.                 move.l  a0,d2                   ; window in d2
  478.                 move.l  d0,d6                   ; color in d6
  479.                 move.l  d1,d4                   ; numgadgets in d4
  480.                 move.l  a1,d0                   ; gadget in d0
  481.                 move.l  a2,d3                   ; requester in d3
  482.                 cldat   d5
  483. ShadLoop:       move.l  d0,a2
  484.                 tst.l   d0
  485.                 beq.s   NoMoreShad
  486.                 move.l  a2,-(sp)
  487.                 move.l  d2,a0
  488.                 move.l  a2,a1
  489.                 move.l  d3,a2
  490.                 move.l  d6,d0
  491.                 bsr     ShadowGadget
  492.                 move.l  (sp)+,a2
  493.                 inc.l   d5
  494.                 cmp.l   d5,d4
  495.                 beq.s   NoMoreShad
  496.                 move.l  gg_NextGadget(a2),d0
  497.                 bra.s   ShadLoop
  498. NoMoreShad:     movem.l (sp)+,d2-d6/a2
  499.                 rts
  500.  
  501. EraseGList:     movem.l d2-d5/a2,-(sp)
  502.                 move.l  a0,d2                   ; window in d2
  503.                 move.l  d0,d4                   ; numgadgets in d4
  504.                 move.l  a1,d0                   ; gadget in d0
  505.                 move.l  a2,d3                   ; requester in d3
  506.                 cldat   d5
  507. ErasLoop:       move.l  d0,a2
  508.                 tst.l   d0
  509.                 beq.s   NoMoreEras
  510.                 move.l  a2,-(sp)
  511.                 move.l  d2,a0
  512.                 move.l  a2,a1
  513.                 move.l  d3,a2
  514.                 bsr     EraseGadget
  515.                 move.l  (sp)+,a2
  516.                 inc.l   d5
  517.                 cmp.l   d5,d4
  518.                 beq.s   NoMoreEras
  519.                 move.l  gg_NextGadget(a2),d0
  520.                 bra.s   ErasLoop
  521. NoMoreEras:     movem.l (sp)+,d2-d5/a2
  522.                 rts
  523.  
  524.